package com.github.rpc4j.consumer.clusters;

import java.util.Random;
import java.util.Set;

public class RandomServiceClustersCall implements ServiceClustersCall {

	Random random = new Random();
		
	public RandomServiceClustersCall() {
	}

	@Override
	public String getCallServer(Set<String> servers) {
	   int size = servers.size();
	   int num =  random.nextInt(size);
	   int i = 0;
	   for(String server:servers){
		   if(num == i ){
			   return server;
		   }
		   i++;
	   }
	   return null;
	}

}
